%undefine _debugsource_packages
%define dont_relink 1

%define reldate 2022-06-28
%define tarname M247_ALT_Linux_RPM_Package
%define rpmname katusha-m247-ps-%{version}.x86_64
%define rel %(echo %{reldate} | sed 's/-//g')
%define pname katusham247

Summary(ru_RU.UTF-8):	Драйвера для принтера Катюша 247(e)
Summary:	Katusha 247(e) cups drivers
Name:		cups-drivers-%{pname}
Version:	1.2.2
Release:	%{rel}.1
License:	KATUSHA
Group:		System/Configuration/Printing
Url:		https://katusha-it.ru/
Vendor:		Katusha
# https://disk.yandex.ru/d/4HMt9Ck2ScpTtA/Драйвера/Linux/Печать/RPM
Source0:	%{reldate}-%{tarname}.tar.gz
BuildRequires:	%{_bindir}/rpm2cpio
BuildRequires:	tar
ExclusiveArch:	x86_64
Requires:	cups

%description
CUPS drivers for Katusha 247(e).

%description -l ru_RU.UTF-8
Драйвера SANE для принтера Катюша 247(e).

%files
%{_usr}/lib/cups/filter/Katusha
%{_datadir}/cups/model/Katusha

#------------------------------------------------------------------

%prep
%setup -n %{reldate}-%{tarname}
rpm2cpio %{rpmname}.rpm | cpio -idmv

%build

%install
mkdir -p %{buildroot}%{_usr}/lib/cups/filter/Katusha/M247/PS/Filters
mkdir -p %{buildroot}%{_datadir}/cups/model/Katusha/M247

install -m755 usr/lib/cups/filter/Katusha/M247/PS/Filters/Katusha_M247_PS %{buildroot}%{_usr}/lib/cups/filter/Katusha/M247/PS/Filters

pushd usr/share/cups/model/Katusha/M247
sed -i \
    -e 's/DefaultPageSize: Letter/DefaultPageSize: A4/g' \
    -e 's/DefaultPageRegion: Letter/DefaultPageRegion: A4/g' \
    -e 's/DefaultImageableArea: Letter/DefaultImageableArea: A4/g' \
    -e 's/DefaultPaperDimension: Letter/DefaultPaperDimension: A4/g' \
    KATUSHA_M247_PS.ppd
install -m644 KATUSHA_M247_PS.ppd %{buildroot}%{_datadir}/cups/model/Katusha/M247
popd
